package com.tbit.uqbike.client.exception;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.LocaleResolver;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Locale;

/**
 * created by Kang on 2019/3/29 10:44
 * description:自定义请求头国际化处理
 */
@Component
public class MyAcceptHeaderLocaleResolver implements LocaleResolver {
    private Locale myLocal;

    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        return myLocal != null ? myLocal : request.getLocale();
    }


    @Override
    public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) {
        this.myLocal = locale;
    }

    public Locale getLocale() {
        return myLocal;
    }


}
